#pragma once

#include "Dependency.h"

#include "NamedElement.h"

namespace uml {

Dependency::Dependency(const QString& umlType)
    : PackageableElement(umlType) {}

void Dependency::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    DirectedRelationship::fromJson(json, errorList);
    PackageableElement::fromJson(json, errorList);
    JsonSerializable::fromJsonArray(clients_, "clients", json, errorList);
    JsonSerializable::fromJsonArray(suppliers_, "suppliers", json, errorList);
}

void Dependency::toJson(QJsonObject& json) {
    DirectedRelationship::toJson(json);
    PackageableElement::toJson(json);
    JsonSerializable::toJsonArray(clients_, "clients", json);
    JsonSerializable::toJsonArray(suppliers_, "suppliers", json);
}

/// <summary>
/// clients getter
/// The Element(s) dependent on the supplier Element(s). In some cases (such as a
/// trace Abstraction) the assignment of direction (that is, the designation of the
/// client Element) is at the discretion of the modeler and is a stipulation.
/// </summary>
vector<shared_ptr<NamedElement>>& Dependency::clients() {
    return clients_;
}

/// <summary>
/// suppliers getter
/// The Element(s) on which the client Element(s) depend in some respect. The
/// modeler may stipulate a sense of Dependency direction suitable for their domain.
/// </summary>
vector<shared_ptr<NamedElement>>& Dependency::suppliers() {
    return suppliers_;
}

} // namespace uml
